Pour installe ArchiSimple :
g++ *.cpp external/tinyxml2/tinyxml2.cpp -std=c++11 -o archisimple.exe
(dans le terminal au directory ArchiSimple93)
archisimple.exe
ArchiSimple <- function(par,exporttype,time) {
setwd("ArchiSimple/src/archisimple93/")
inc <-0
for (variety in par$exportName) {
# Print l'avancé de la boucle
inc <- inc+1
print(paste("Simulation pour :", variety, "i=", inc, '========================'))
#Update les paramètres
## Regarde chaque colone de params, si la même est dans par, il remplace la colonne de params par celle de par
params <- params %>%
mutate(across(everything(), ~ ifelse(cur_column() %in% names(par), par[inc,][[cur_column()]],.))) %>%
mutate(exportType = exporttype) %>%
mutate(simtime=time)
print(params)
# Créaction du fichier paramètre lu par ArchiSimple
write_archisimple_XML(params, path = "parameter.xml")
# Run ArchiSimple
system("./archisimple")
}
setwd("../../../")
}# Fonction qui fait un plot pour chaque jour jusqu'à jour max
time_plot <- function(data, variety) {
for (i in 1:8) {
print(i)
print(paste('Plot pour',variety,'jour',i*5))
print(
filter(data,sim==variety, Jour <= i*5) %>%
ggplot() +
theme_classic() +
geom_segment(aes(x = X1, y = -Z1, xend = X2, yend = -Z2, color=Diam), alpha=0.9) +
scale_x_continuous(limits=c(-500,+500)) +
scale_y_continuous(limits = c(-2000, 0)) +
scale_color_viridis(limits=c(0,2.5),option = "turbo") +
coord_fixed()+
labs(title=paste(variety,'jour',i*5),col='Diamètre')
)
}
}Importe le fichier ‘base_parameter.xml’ ainsi qu’un dataframe avec les valeurs qui doivent être modifiées.
# Import des paramètres de base
params <- read_archisimple_xml("base_parameter.xml")
# Insérer les différents paramètres à modifier dans le batch
par_sorgho <- data.frame(
exportName=c('Amiggo','Biggben','Hyperion','Juno','Swingg','Vegga'),
dmin=c( 0.1567 ,0.1567 ,0.1567 ,0.1567 ,0.1567 ,0.1297),
RDM = c( 0.1874 ,0.2022 ,0.228 ,0.17545 ,0.1745 ,0.1611)
)ArchiSimple(par=par_sorgho,exporttype = 1,time = 40)## [1] "Simulation pour : Amiggo i= 1 ========================"
## # A tibble: 1 × 27
## ageAdv CVDD dAdv distAdv dmax dmin dSem EL erAdv erSem exportName
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 12 0.2449 0.3407 30 6.984537 0.157 0.08… 33.0… 1.2 1 Amiggo
## # ℹ 16 more variables: exportType <dbl>, GDs <chr>, IPD <chr>, LDC <chr>,
## # maxAdv <chr>, maxSem <chr>, pdmax <chr>, pdmin <chr>, PDT <chr>, RDM <dbl>,
## # SGC <chr>, sim_length <chr>, simtime <dbl>, TMD <chr>, TrInt <chr>,
## # TrT <chr>
## [1] "Simulation pour : Biggben i= 2 ========================"
## # A tibble: 1 × 27
## ageAdv CVDD dAdv distAdv dmax dmin dSem EL erAdv erSem exportName
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 12 0.2449 0.3407 30 6.984537 0.157 0.08… 33.0… 1.2 1 Biggben
## # ℹ 16 more variables: exportType <dbl>, GDs <chr>, IPD <chr>, LDC <chr>,
## # maxAdv <chr>, maxSem <chr>, pdmax <chr>, pdmin <chr>, PDT <chr>, RDM <dbl>,
## # SGC <chr>, sim_length <chr>, simtime <dbl>, TMD <chr>, TrInt <chr>,
## # TrT <chr>
## [1] "Simulation pour : Hyperion i= 3 ========================"
## # A tibble: 1 × 27
## ageAdv CVDD dAdv distAdv dmax dmin dSem EL erAdv erSem exportName
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 12 0.2449 0.3407 30 6.984537 0.157 0.08… 33.0… 1.2 1 Hyperion
## # ℹ 16 more variables: exportType <dbl>, GDs <chr>, IPD <chr>, LDC <chr>,
## # maxAdv <chr>, maxSem <chr>, pdmax <chr>, pdmin <chr>, PDT <chr>, RDM <dbl>,
## # SGC <chr>, sim_length <chr>, simtime <dbl>, TMD <chr>, TrInt <chr>,
## # TrT <chr>
## [1] "Simulation pour : Juno i= 4 ========================"
## # A tibble: 1 × 27
## ageAdv CVDD dAdv distAdv dmax dmin dSem EL erAdv erSem exportName
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 12 0.2449 0.3407 30 6.984537 0.157 0.08… 33.0… 1.2 1 Juno
## # ℹ 16 more variables: exportType <dbl>, GDs <chr>, IPD <chr>, LDC <chr>,
## # maxAdv <chr>, maxSem <chr>, pdmax <chr>, pdmin <chr>, PDT <chr>, RDM <dbl>,
## # SGC <chr>, sim_length <chr>, simtime <dbl>, TMD <chr>, TrInt <chr>,
## # TrT <chr>
## [1] "Simulation pour : Swingg i= 5 ========================"
## # A tibble: 1 × 27
## ageAdv CVDD dAdv distAdv dmax dmin dSem EL erAdv erSem exportName
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 12 0.2449 0.3407 30 6.984537 0.157 0.08… 33.0… 1.2 1 Swingg
## # ℹ 16 more variables: exportType <dbl>, GDs <chr>, IPD <chr>, LDC <chr>,
## # maxAdv <chr>, maxSem <chr>, pdmax <chr>, pdmin <chr>, PDT <chr>, RDM <dbl>,
## # SGC <chr>, sim_length <chr>, simtime <dbl>, TMD <chr>, TrInt <chr>,
## # TrT <chr>
## [1] "Simulation pour : Vegga i= 6 ========================"
## # A tibble: 1 × 27
## ageAdv CVDD dAdv distAdv dmax dmin dSem EL erAdv erSem exportName
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 12 0.2449 0.3407 30 6.984537 0.130 0.08… 33.0… 1.2 1 Vegga
## # ℹ 16 more variables: exportType <dbl>, GDs <chr>, IPD <chr>, LDC <chr>,
## # maxAdv <chr>, maxSem <chr>, pdmax <chr>, pdmin <chr>, PDT <chr>, RDM <dbl>,
## # SGC <chr>, sim_length <chr>, simtime <dbl>, TMD <chr>, TrInt <chr>,
## # TrT <chr>
setwd("ArchiSimple/src/archisimple93/")
sims <- NULL
for (variety in c('Amiggo','Biggben','Hyperion','Juno','Swingg','Vegga')) {
rs <- fread(paste0(variety,'.txt')) %>%
mutate(sim = as.factor(variety))
sims <- rbind(sims,rs)
}
setwd("../../../") for (variety in levels(sims$sim)) {
time_plot(sims,variety = variety)
print(paste('La profondeur max du système racinaire après 40 jours=',max(subset(sims,sim==variety)$Z1),'[mm]'))
print(paste0('Le système racinaire après 40 jours s étend de',min(subset(sims,sim==variety)$X1),'[mm] à ',max(subset(sims,sim==variety)$X1),'[mm] soit une largeur totale de :',
max(subset(sims,sim==variety)$X1)-min(subset(sims,sim==variety)$X1),'[mm]'))
print(paste('Le diamètre moyen des racines après 40 jours est =',mean(subset(sims, sim==variety)$Diam)))
}## [1] 1
## [1] "Plot pour Amiggo jour 5"
## [1] 2
## [1] "Plot pour Amiggo jour 10"
## [1] 3
## [1] "Plot pour Amiggo jour 15"
## [1] 4
## [1] "Plot pour Amiggo jour 20"
## [1] 5
## [1] "Plot pour Amiggo jour 25"
## [1] 6
## [1] "Plot pour Amiggo jour 30"
## [1] 7
## [1] "Plot pour Amiggo jour 35"
## [1] 8
## [1] "Plot pour Amiggo jour 40"
## [1] "La profondeur max du système racinaire après 40 jours= 1679.77 [mm]"
## [1] "Le système racinaire après 40 jours s étend de-398.06[mm] à 433.18[mm] soit une largeur totale de :831.24[mm]"
## [1] "Le diamètre moyen des racines après 40 jours est = 0.637785562308244"
## [1] 1
## [1] "Plot pour Biggben jour 5"
## [1] 2
## [1] "Plot pour Biggben jour 10"
## [1] 3
## [1] "Plot pour Biggben jour 15"
## [1] 4
## [1] "Plot pour Biggben jour 20"
## [1] 5
## [1] "Plot pour Biggben jour 25"
## [1] 6
## [1] "Plot pour Biggben jour 30"
## Warning: Removed 67 rows containing missing values (`geom_segment()`).
## [1] 7
## [1] "Plot pour Biggben jour 35"
## Warning: Removed 805 rows containing missing values (`geom_segment()`).
## [1] 8
## [1] "Plot pour Biggben jour 40"
## Warning: Removed 3423 rows containing missing values (`geom_segment()`).
## [1] "La profondeur max du système racinaire après 40 jours= 1561.91 [mm]"
## [1] "Le système racinaire après 40 jours s étend de-845.43[mm] à 550.1[mm] soit une largeur totale de :1395.53[mm]"
## [1] "Le diamètre moyen des racines après 40 jours est = 0.641376610412702"
## [1] 1
## [1] "Plot pour Hyperion jour 5"
## [1] 2
## [1] "Plot pour Hyperion jour 10"
## [1] 3
## [1] "Plot pour Hyperion jour 15"
## [1] 4
## [1] "Plot pour Hyperion jour 20"
## [1] 5
## [1] "Plot pour Hyperion jour 25"
## [1] 6
## [1] "Plot pour Hyperion jour 30"
## [1] 7
## [1] "Plot pour Hyperion jour 35"
## [1] 8
## [1] "Plot pour Hyperion jour 40"
## Warning: Removed 229 rows containing missing values (`geom_segment()`).
## [1] "La profondeur max du système racinaire après 40 jours= 1677.14 [mm]"
## [1] "Le système racinaire après 40 jours s étend de-601.25[mm] à 407.95[mm] soit une largeur totale de :1009.2[mm]"
## [1] "Le diamètre moyen des racines après 40 jours est = 0.662578601439722"
## [1] 1
## [1] "Plot pour Juno jour 5"
## [1] 2
## [1] "Plot pour Juno jour 10"
## [1] 3
## [1] "Plot pour Juno jour 15"
## [1] 4
## [1] "Plot pour Juno jour 20"
## [1] 5
## [1] "Plot pour Juno jour 25"
## [1] 6
## [1] "Plot pour Juno jour 30"
## [1] 7
## [1] "Plot pour Juno jour 35"
## [1] 8
## [1] "Plot pour Juno jour 40"
## Warning: Removed 21 rows containing missing values (`geom_segment()`).
## [1] "La profondeur max du système racinaire après 40 jours= 1503.8 [mm]"
## [1] "Le système racinaire après 40 jours s étend de-543.14[mm] à 487.94[mm] soit une largeur totale de :1031.08[mm]"
## [1] "Le diamètre moyen des racines après 40 jours est = 0.639848519873268"
## [1] 1
## [1] "Plot pour Swingg jour 5"
## [1] 2
## [1] "Plot pour Swingg jour 10"
## [1] 3
## [1] "Plot pour Swingg jour 15"
## [1] 4
## [1] "Plot pour Swingg jour 20"
## [1] 5
## [1] "Plot pour Swingg jour 25"
## [1] 6
## [1] "Plot pour Swingg jour 30"
## [1] 7
## [1] "Plot pour Swingg jour 35"
## [1] 8
## [1] "Plot pour Swingg jour 40"
## Warning: Removed 194 rows containing missing values (`geom_segment()`).
## [1] "La profondeur max du système racinaire après 40 jours= 1430.85 [mm]"
## [1] "Le système racinaire après 40 jours s étend de-597.34[mm] à 555.39[mm] soit une largeur totale de :1152.73[mm]"
## [1] "Le diamètre moyen des racines après 40 jours est = 0.638085609173179"
## [1] 1
## [1] "Plot pour Vegga jour 5"
## [1] 2
## [1] "Plot pour Vegga jour 10"
## [1] 3
## [1] "Plot pour Vegga jour 15"
## [1] 4
## [1] "Plot pour Vegga jour 20"
## [1] 5
## [1] "Plot pour Vegga jour 25"
## [1] 6
## [1] "Plot pour Vegga jour 30"
## [1] 7
## [1] "Plot pour Vegga jour 35"
## Warning: Removed 49 rows containing missing values (`geom_segment()`).
## [1] 8
## [1] "Plot pour Vegga jour 40"
## Warning: Removed 430 rows containing missing values (`geom_segment()`).
## [1] "La profondeur max du système racinaire après 40 jours= 1553.79 [mm]"
## [1] "Le système racinaire après 40 jours s étend de-596.83[mm] à 564.78[mm] soit une largeur totale de :1161.61[mm]"
## [1] "Le diamètre moyen des racines après 40 jours est = 0.618091977531753"
params_maize <- data.frame(
ageAdv = 7,
CVDD = 0.3,
dAdv = 0.3900776,
distAdv = 20,
dmax = 4.5,
dmin = 0.14,
dSem = 0.1, #0.02667,si pas ouf
EL = 32.5, #51,
erAdv = 0.8,
erSem = 0.5,
exportName = 'maize' ,
exportType = 1,
GDs = 50,
IPD = 2,
LDC = 3000,
maxAdv = 40,
maxSem = 7,
pdmax = 0.8,
pdmin = 0,
PDT = 4.5,
RDM = 0.12,
SGC = 0,
sim_length = 20,
simtime = 30,
TMD = 0.08,
TrInt = 0.01,
TrT = 1
)ArchiSimple(par=params_maize,exporttype = 1,time = 40)## [1] "Simulation pour : maize i= 1 ========================"
## # A tibble: 1 × 27
## ageAdv CVDD dAdv distAdv dmax dmin dSem EL erAdv erSem exportName
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
## 1 7 0.3 0.390 20 4.5 0.14 0.1 32.5 0.8 0.5 maize
## # ℹ 16 more variables: exportType <dbl>, GDs <dbl>, IPD <dbl>, LDC <dbl>,
## # maxAdv <dbl>, maxSem <dbl>, pdmax <dbl>, pdmin <dbl>, PDT <dbl>, RDM <dbl>,
## # SGC <dbl>, sim_length <dbl>, simtime <dbl>, TMD <dbl>, TrInt <dbl>,
## # TrT <dbl>
setwd("ArchiSimple/src/archisimple93/")
maize <- fread('maize.txt') %>%
mutate(sim='maize')
setwd("../../../") time_plot(data = maize,variety = 'maize')## [1] 1
## [1] "Plot pour maize jour 5"
## [1] 2
## [1] "Plot pour maize jour 10"
## [1] 3
## [1] "Plot pour maize jour 15"
## [1] 4
## [1] "Plot pour maize jour 20"
## [1] 5
## [1] "Plot pour maize jour 25"
## [1] 6
## [1] "Plot pour maize jour 30"
## [1] 7
## [1] "Plot pour maize jour 35"
## [1] 8
## [1] "Plot pour maize jour 40"
print(paste('La profondeur max du système racinaire=',max(maize$Z1),'[mm]'))## [1] "La profondeur max du système racinaire= 1492.72 [mm]"
print(paste0('Le système racinaire s étend de',min(maize$X1),'[mm] à ',max(maize$X1),'[mm] soit une largeur totale de :', max(maize$X1)-min(maize$X1),'[mm]'))## [1] "Le système racinaire s étend de-183.79[mm] à 248.34[mm] soit une largeur totale de :432.13[mm]"
print(paste('Le diamètre moyen des racines est =',mean(maize$Diam)))## [1] "Le diamètre moyen des racines est = 0.57199945380774"
La fonction archiDART::root donne les attributs de chaque racine.